package cn.stylefeng.guns.modular.api;

import cn.stylefeng.guns.modular.business.entity.Certification;
import cn.stylefeng.guns.modular.business.model.dto.CertificationDto;
import cn.stylefeng.guns.modular.business.service.CertificationService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 实名认证
 *
 * @Author pzp .
 * @Date 2019/7/2610:34
 */
@RestController
@RequestMapping("/gunsApi/certification")
public class CertificationApi extends BaseController {

    @Autowired
    private CertificationService certificationService;

    @ApiOperation("实名认证")
    @PostMapping("/add")
    public ResponseData add(@RequestBody CertificationDto certificationDto) {
        certificationService.addOrUpdate(certificationDto);
        return ResponseData.success();
    }

    @ApiOperation("实名认证明细")
    @GetMapping("/detail")
    public ResponseData detail(@RequestParam long userId) {
        Certification certification = certificationService.detail(userId);
        if (null==certification){
            return ResponseData.error("用户未做实名认证");
        }
        return ResponseData.success(certification);
    }


}
